import common.TreeNode;

/**
 * @author tmh
 * @date 2024/9/28 19:22
 * @description
 */
public class T104二叉树的最大深度 {
    public int maxDepth(TreeNode root) {
        return dfs(root);
    }

    private int dfs(TreeNode root) {
        if (root == null) {
            return 0;
        }
        int left = dfs(root.left);
        int right = dfs(root.right);
        return Math.max(left, right) + 1;
    }
}
